/*
 * 
 *  This file is part of Sourceprojects.org Lycia Copyright 2010 noctarius
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */
package org.sourceprojects.lycia.internal.dom;

import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.UserDataHandler;

public class AttrImpl implements Attr {

	private final Element element;
	private final String value;
	private final String name;
	private final String namespaceURI;
	private final String prefix;

	public AttrImpl(Element element, String value, String name,
			String namespaceURI, String prefix) {

		this.element = element;
		this.value = value;
		this.name = name;
		this.namespaceURI = namespaceURI;
		this.prefix = prefix;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public Element getOwnerElement() {
		return element;
	}

	@Override
	public TypeInfo getSchemaTypeInfo() {
		return element.getSchemaTypeInfo();
	}

	@Override
	public boolean getSpecified() {
		return false;
	}

	@Override
	public String getValue() {
		return value;
	}

	@Override
	public boolean isId() {
		return false;
	}

	@Override
	public void setValue(String value) throws DOMException {
		throw new UnsupportedOperationException("setValue is not supported");
	}

	@Override
	public Node appendChild(Node newChild) throws DOMException {
		throw new UnsupportedOperationException("appendChild is not supported");
	}

	@Override
	public Node cloneNode(boolean deep) {
		throw new UnsupportedOperationException("cloneNode is not supported");
	}

	@Override
	public short compareDocumentPosition(Node other) throws DOMException {
		throw new UnsupportedOperationException(
				"compareDocumentPosition is not supported");
	}

	@Override
	public NamedNodeMap getAttributes() {
		return null;
	}

	@Override
	public String getBaseURI() {
		return namespaceURI;
	}

	@Override
	public NodeList getChildNodes() {
		return null;
	}

	@Override
	public Object getFeature(String feature, String version) {
		return null;
	}

	@Override
	public Node getFirstChild() {
		return null;
	}

	@Override
	public Node getLastChild() {
		return null;
	}

	@Override
	public String getLocalName() {
		return name;
	}

	@Override
	public String getNamespaceURI() {
		return namespaceURI;
	}

	@Override
	public Node getNextSibling() {
		return null;
	}

	@Override
	public String getNodeName() {
		return name;
	}

	@Override
	public short getNodeType() {
		return Node.ATTRIBUTE_NODE;
	}

	@Override
	public String getNodeValue() throws DOMException {
		return value;
	}

	@Override
	public Document getOwnerDocument() {
		return element.getOwnerDocument();
	}

	@Override
	public Node getParentNode() {
		return null;
	}

	@Override
	public String getPrefix() {
		return prefix;
	}

	@Override
	public Node getPreviousSibling() {
		return null;
	}

	@Override
	public String getTextContent() throws DOMException {
		return value;
	}

	@Override
	public Object getUserData(String key) {
		return null;
	}

	@Override
	public boolean hasAttributes() {
		return false;
	}

	@Override
	public boolean hasChildNodes() {
		return false;
	}

	@Override
	public Node insertBefore(Node newChild, Node refChild) throws DOMException {
		throw new UnsupportedOperationException("insertBefore is not supported");
	}

	@Override
	public boolean isDefaultNamespace(String namespaceURI) {
		return element.isDefaultNamespace(namespaceURI);
	}

	@Override
	public boolean isEqualNode(Node arg) {
		return arg.equals(this);
	}

	@Override
	public boolean isSameNode(Node other) {
		return isEqualNode(other);
	}

	@Override
	public boolean isSupported(String feature, String version) {
		return false;
	}

	@Override
	public String lookupNamespaceURI(String prefix) {
		return element.lookupNamespaceURI(prefix);
	}

	@Override
	public String lookupPrefix(String namespaceURI) {
		return element.lookupPrefix(namespaceURI);
	}

	@Override
	public void normalize() {
	}

	@Override
	public Node removeChild(Node oldChild) throws DOMException {
		throw new UnsupportedOperationException("removeChild is not supported");
	}

	@Override
	public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
		throw new UnsupportedOperationException("replaceChild is not supported");
	}

	@Override
	public void setNodeValue(String nodeValue) throws DOMException {
		throw new UnsupportedOperationException("setNodeValue is not supported");
	}

	@Override
	public void setPrefix(String prefix) throws DOMException {
		throw new UnsupportedOperationException("setPrefix is not supported");
	}

	@Override
	public void setTextContent(String textContent) throws DOMException {
		throw new UnsupportedOperationException(
				"setTextContent is not supported");
	}

	@Override
	public Object setUserData(String key, Object data, UserDataHandler handler) {
		throw new UnsupportedOperationException("setUserData is not supported");
	}

}
